layui.use(['table', 'jquery', 'element', 'form'], function () {
    var table = layui.table;
    var $ = layui.$;
    var element = layui.element;
    var form = layui.form;

    table.render({
        elem: '#table'
        , url: '/emp/getEntry'
        , where: {
            search: 0
        }
        , id: "entry-table"
        , page: true
        , height: 512
        , limit: 10
        , cols: [[
            {field: 'emp', title: '员工编号'}
            , {field: 'empName', title: '员工'}
            , {field: 'time', title: '入职时间', width: 190}
            , {field: 'department', title: '部门编号'}
            // ,{field:'area',title:'区域'}
            // ,{field:'nativePlace',title:'籍贯'}
            // ,{field:'state',title:'状态'}
            , {field: 'dName', title: '入职部门'}
            , {field: 'remarks', title: '备注'}
            // , {field: 'operation', title: '操作', fixed: 'right', width: 110, align: 'center', toolbar: '#barDemo'}
        ]]
    });


    element.on('tab(tab)', function (data) {
        var index = data.index;
        console.log(index);
        if (index == 0) {
            location.href = '/emp';
        } else if (index == 1) {
            location.href = '/emp/department';
        } else if (index == 2) {
            location.href = '/emp/entry';
        }
        return false;
    });

    form.on('submit(search)', function (data) {
        table.reload('entry-table', {
            where: {
                search: data.field.id
            }
        });

        return false;
    });


});